//
//  XJPayHeaderView.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/6/13.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJPayHeaderView.h"
@interface XJPayHeaderView()
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *needPayLb; // 需要支付lb

@property(nonatomic, strong) UIView *div1;
@property (nonatomic, strong) UILabel *symbolOfRMBLb; //￥
@property (nonatomic, strong) UILabel *payLb; // 支付金额Lb



@end

@implementation XJPayHeaderView

#pragma mark - 1.init

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
    }
    return self;
}

- (void)setupView {
    [self addSubview:self.bgView];
    
    [self.bgView addSubview:self.needPayLb];
    
    [self.bgView addSubview:self.div1];
    [self.div1 addSubview:self.symbolOfRMBLb];
    [self.div1 addSubview:self.payLb];
}

#pragma mark - 2.lazy
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}
- (UILabel *)needPayLb {
    if (!_needPayLb) {
        _needPayLb = [UILabel new];
        _needPayLb.text = @"需要支付";
        _needPayLb.font = XJFONTSET_M(17.0);
    }
    return _needPayLb;
}


- (UIView *)div1 {
    if (!_div1) {
        _div1 = [UIView new];
//        _div1.backgroundColor = [UIColor redColor];
    }
    return _div1;
}

// 10
- (UILabel *)symbolOfRMBLb {
    if (!_symbolOfRMBLb) {
        _symbolOfRMBLb = [UILabel new];
        _symbolOfRMBLb.text = @"￥";
        _symbolOfRMBLb.font = XJFONTSET_M(20.0);
//        _symbolOfRMBLb.backgroundColor = [UIColor lightGrayColor];
    }
    return _symbolOfRMBLb;
}
- (UILabel *)payLb {
    if (!_payLb) {
        _payLb = [UILabel new];
        _payLb.text = @"666.00";
        _payLb.font = XJFONTSET_M(30.0);
//        _payLb.backgroundColor = [UIColor greenColor];
    }
    return _payLb;
}

#pragma mark - 3.layout


//self H: 90
- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    
    [self.needPayLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView.mas_left).offset(15);
        make.top.equalTo(self.bgView.mas_top).offset(10);
        make.size.mas_equalTo(CGSizeMake(100, 30));
    }];
    
    
    
    [self.div1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.needPayLb.mas_bottom);
        make.left.equalTo(self.bgView.mas_left).offset(15);
        make.right.bottom.equalTo(self.bgView);
    }];
    
    [self.symbolOfRMBLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.div1.mas_left);
        make.centerY.equalTo(self.div1.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(20, 30));
    }];
    
    [self.payLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.symbolOfRMBLb.mas_right);
        
        //✅
        make.centerY.equalTo(self.div1.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(200, 40));
    }];
}

#pragma mark - 5.bug :￥ 和钱数不再一条线上啊啊啊啊啊

#pragma mark - 4.configure
- (void)configureBalance:(NSString *)balance {
    
    self.payLb.text = [NSString stringWithFormat:@"%.1f",[balance floatValue]];
    
}



@end
